package com.haolijun.eecms.controller;

import cn.hutool.json.JSONUtil;
import com.haolijun.eecms.common.R;
import com.haolijun.eecms.controller.form.ApplyActiveOrCancelForm;
import com.haolijun.eecms.entity.TbApply;
import com.haolijun.eecms.service.ApplyService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * @ClassName ApplyController
 * @Description TODO
 * @Author hljstart
 * @Date 2023/3/12 13:14
 * @Version 1.0
 */
@RestController
@RequestMapping("/apply")
@Tag(name = "ApplyController",description = "报名Web接口")
public class ApplyController {
    @Autowired
    private ApplyService applyService;
    @PostMapping("/applyActiveOrCancel")
    @Operation(description = "报名或取消报名")
    public R applyActiveOrCancel(@Valid @RequestBody ApplyActiveOrCancelForm form){
        TbApply apply = JSONUtil.parse(form).toBean(TbApply.class);
        R r = applyService.applyActiveOrCancel(apply);
        return r;
    }
}
